package com.ruoyi.quartz.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.quartz.domain.BaseType;
import com.ruoyi.quartz.service.IBaseTypeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/base/menu")
public class BaseTypeController extends BaseController {

    @Resource
    private IBaseTypeService iBaseTypeService;

    @GetMapping("/list")
    public TableDataInfo list(BaseType baseType)
    {
        startPage();
        List<BaseType> list = iBaseTypeService.selectAll(baseType);
        return getDataTable(list);
    }

    @PostMapping
    public AjaxResult add(@RequestBody BaseType baseType) {
        return toAjax(iBaseTypeService.addBaseMenu(baseType));
    }

    @GetMapping(value = "/{bm_id}")
    public AjaxResult getInfo(@PathVariable Integer bm_id)
    {
        return success(iBaseTypeService.selectMenuById(bm_id));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BaseType baseType){
        return toAjax(iBaseTypeService.updateBaseMenu(baseType));
    }

    @DeleteMapping("/{bm_ids}")
    public AjaxResult remove(@PathVariable Integer[] bm_ids){
        iBaseTypeService.deleteMenuByIds(bm_ids);
        return success();
    }

}
